#!/usr/bin/env python3
"""
项目启动脚本
"""
import os
import sys
from pathlib import Path

# 添加项目根目录到Python路径
project_root = Path(__file__).parent
sys.path.insert(0, str(project_root))

from app import app


def main():
    """主启动函数"""
    # 检查环境变量
    if not os.getenv("SECRET_KEY"):
        print("警告: SECRET_KEY环境变量未设置，使用默认值")
    
    if not os.getenv("JWT_SECRET_KEY"):
        print("警告: JWT_SECRET_KEY环境变量未设置，使用默认值")
    
    # 启动应用
    host = os.getenv("HOST", "0.0.0.0")
    port = int(os.getenv("PORT", 5000))
    debug = os.getenv("DEBUG", "False").lower() == "true"
    
    print(f"启动 {app.config.get('PROJECT_NAME', 'Python API Project')}")
    print(f"环境: {os.getenv('FLASK_ENV', 'development')}")
    print(f"地址: http://{host}:{port}")
    print(f"调试模式: {debug}")
    
    app.run(host=host, port=port, debug=debug)


if __name__ == "__main__":
    main()